import { AxiosPromise } from 'axios'
import request from './request'
//获取提现设置
export function getWithdrawSet() {
  return request({
    url: '/set/getWithdrawSet',
    method: 'get',
  })
}
// 保存提现设置
export function saveWithdrawSet(data) {
  return request({
    url: '/set/saveWithdrawSet',
    method: 'put',
    data,
  })
}

/**
 * 获取提现单列表
 * @param data - 请求参数
 * @param {number} data.dateType - 日期类型：1-今天，2-本周，3-本月，4-过去三个月，5-自定义时间区间
 * @param {string} data.endTime - 结束时间
 * @param {string} data.engineer - 工程师名称
 * @param {number} data.fieldType - 字段类型：1-申请提现时间
 * @param {string} data.keyword - 关键词搜索
 * @param {number} data.limit - 每页显示数量
 * @param {string} data.networkId - 服务商ID
 * @param {number} data.page - 当面页码
 * @param {string} data.startTime - 搜索开始时间
 * @param {number} data.status - 1-提现待审核，2-付款中/等待打款，3-打款完成，4-失败，5-驳回
 * @param {string} data.workNo - 工单单号
 */
export function getWithdrawList(
  data: WithdrawalAPIRequest.GetListParam,
): AxiosPromise<APIResponseList<WithdrawalAPIResponse.ListItem>> {
  return request({
    url: '/withdraw/getList',
    method: 'post',
    data,
  })
}

// 根据商家获取服务人员下拉数据
export function getNetworkEmpSelect(data) {
  return request({
    url: '/networkSelect/getNetworkEmpSelect',
    method: 'post',
    data,
  })
}
// 根据服务人员ID获取对应服务商下拉数据
export function getNetworkByNetworkEmpIdSelect(networkEmpId) {
  return request({
    url: '/networkSelect/getNetworkByNetworkEmpIdSelect/' + networkEmpId,
    method: 'get',
  })
}
// 获取服务人员银行卡
export function getNetworkBandSelect(networkEmpId) {
  return request({
    url: '/networkSelect/getNetworkBandSelect/' + networkEmpId,
    method: 'post',
  })
}
// 根据服务商ID获取提现手续费策略
export function getWithdrawHandlingFeeStrategy(networkId) {
  return request({
    url: '/network/strategy/getWithdrawHandlingFeeStrategy/' + networkId,
    method: 'get',
  })
}
// 获取可提现工单列表
export function getWithdrawOrderList(data, networkId, networkEmpId) {
  return request({
    url: `/withdraw/getWithdrawOrderList/${networkId}/${networkEmpId}`,
    method: 'post',
    data,
  })
}

// 保存提现单
export function saveWithdraw(data) {
  return request({
    url: `/withdraw/save`,
    method: 'post',
    data,
  })
}
// 获取提现单详情
export function getWithdrawDetail(id) {
  return request({
    url: `/withdraw/getDetail/${id}`,
    method: 'get',
  })
}
//根据提现单ID获取提现工单
export function getWithdrawOrder(id) {
  return request({
    url: `/withdraw/getWithdrawOrder/${id}`,
    method: 'get',
  })
}
//根据提现单ID获取操作日志
export function getWithdrawLog(data, id) {
  return request({
    url: `/withdraw/getWithdrawLog/${id}`,
    method: 'post',
    data,
  })
}
//审核提现单
export function checkWithdraw(data) {
  return request({
    url: `/withdraw/checkWithdraw`,
    method: 'post',
    data,
  })
}
// 获取更改提现单前的查询
export function getBeforeUpdateSelect(id) {
  return request({
    url: `/withdraw/getBeforeUpdateSelect/${id}`,
    method: 'get',
  })
}
// 批量完成打款
export function finishWithdraw(data) {
  return request({
    url: `/withdraw/finishWithdraw`,
    method: 'post',
    data,
  })
}

// 更新提现单
export function updateWithdraw(id,data) {
  return request({
    url: `/withdraw/updateWithdraw/${id}`,
    method: 'post',
    data,
  })
}
